package co.edu.udem.service.notification;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import co.edu.udem.dao.NotificationDao;
import co.edu.udem.domain.Notification;
import co.edu.udem.service.GenericDTO;
import co.edu.udem.service.GenericService;

/**
 * Service for processing notifications
 * 
 */
@Service("notificationService")
public class NotificationService implements GenericService {

	@Autowired
	private NotificationDao notificationDao;

	/**
	 * Retrieves all notifications
	 * 
	 * @return a list of notification
	 */
	public List<Notification> getAll() {
		return notificationDao.getAllNotifications();
	}

	/**
	 * Retrieves a single notification
	 */
	public Notification get(Integer id) {
		return notificationDao.getNotificationById(id);
	}

	/**
	 * Adds a new notification
	 */
	public void add(Notification notification) {
		notificationDao.saveNotification(notification);
	}

	/**
	 * Deletes an existing notification
	 * 
	 * @param id
	 *            the id of the existing notification
	 */
	public void delete(Integer id) {
		notificationDao.deleteNotification(id);
	}

	public int getValidUuid() {
		return notificationDao.getValidUuid();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see co.edu.udem.service.GenericService#getObjectList(java.util.Date,
	 * java.lang.String[][], java.lang.Object[])
	 */
	public List<GenericDTO> getObjectList(Date serviceDate, String[][] orderBy,
			Object... params) {
		return NotificationDTO.populateDTOList(notificationDao
				.getNotificationListByUserSubject((String) params[0],
						Integer.valueOf((String) params[1])));
	}
}
